package version4.common.Message;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;


@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class RpcResponse implements Serializable {
    //状态信息
    private int code;
    private String message;
    //具体数据
    private Object data;
    // 数据类型
    private Class<?> dataType;

    public static RpcResponse sussess(Object data){
        return RpcResponse.builder().code(200).data(data).dataType(data.getClass()).build();
    }
    public static RpcResponse fail(String message){
        return RpcResponse.builder().code(500).message(message).build();
    }
}

